/*    */ package com.hs.activation.service.impl;
/*    */ 
/*    */ import com.baomidou.mybatisplus.core.conditions.Wrapper;
/*    */ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
/*    */ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
/*    */ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/*    */ import com.hs.activation.common.result.Result;
/*    */ import com.hs.activation.common.result.ResultCode;
/*    */ import com.hs.activation.common.utils.BaseUtil;
/*    */ import com.hs.activation.common.utils.JwtUtil;
/*    */ import com.hs.activation.entity.User;
/*    */ import com.hs.activation.mapper.UserMapper;
/*    */ import com.hs.activation.service.IUserService;
/*    */ import com.hs.activation.vo.UserLoginVO;
/*    */ import com.hs.activation.vo.UserResetPasswordVO;
/*    */ import java.lang.invoke.SerializedLambda;
/*    */ import java.util.ArrayList;
/*    */ import java.util.List;
/*    */ import org.springframework.stereotype.Service;
/*    */ import org.springframework.util.DigestUtils;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ @Service
/*    */ public class IUserServiceImpl
/*    */   extends ServiceImpl<UserMapper, User>
/*    */   implements IUserService
/*    */ {
/*    */   public Result login(UserLoginVO loginVO) {
/* 37 */     User user = findByAccount(loginVO.getAccount());
/* 38 */     if (user != null) {
/* 39 */       if (user.getPassword().equals(DigestUtils.md5DigestAsHex(loginVO.getPassword().getBytes()))) {
/* 40 */         return new Result("登陆成功", Integer.valueOf(ResultCode.OK.code), JwtUtil.getToken(user));
/*    */       }
/* 42 */       return new Result("密码错误", Integer.valueOf(ResultCode.Fail.code));
/*    */     } 
/*    */     
/* 45 */     return new Result("用户不存在", Integer.valueOf(ResultCode.Fail.code));
/*    */   }
/*    */ 
/*    */ 
/*    */   
/*    */   public User findByUserName(String userName) {
/* 51 */     LambdaQueryWrapper<User> query = new LambdaQueryWrapper();
/* 52 */     ((LambdaQueryWrapper)query.eq(User::getUserName, userName)).last("limit 1");
/* 53 */     return (User)getOne((Wrapper)query);
/*    */   }
/*    */ 
/*    */   
/*    */   public User findByAccount(String account) {
/* 58 */     LambdaQueryWrapper<User> query = new LambdaQueryWrapper();
/* 59 */     ((LambdaQueryWrapper)query.eq(User::getAccount, account)).last("limit 1");
/* 60 */     return (User)getOne((Wrapper)query);
/*    */   }
/*    */ 
/*    */   
/*    */   public boolean resetPassword(UserResetPasswordVO resetPassword) {
/* 65 */     return true;
/*    */   }
/*    */ 
/*    */   
/*    */   public List<String> getEmailList() {
/* 75 */     List<User> list = list();
/* 76 */     List<String> result = new ArrayList<>();
/* 77 */     for (User user : list) {
/* 78 */       if (!BaseUtil.isEmpty(user.getEmail())) {
/* 79 */         result.add(user.getEmail());
/*    */       }
/*    */     } 
/* 82 */     return result;
/*    */   }
/*    */ 
/*    */   
/*    */   public User getUser(String token) {
/* 87 */     Integer id = JwtUtil.getCurrentUserId();
/* 88 */     return (User)getById(id);
/*    */   }
/*    */ }


/* Location:              C:\Users\yzc\Desktop\新建文件夹 (3)\activation-0.0.16.jar!\BOOT-INF\classes\com\hs\activation\service\impl\IUserServiceImpl.class
 * Java compiler version: 16 (60.0)
 * JD-Core Version:       1.1.3
 */